package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.EquipmentRiskAssessment;
import com.ruoyi.system.service.IEquipmentRiskAssessmentService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 安全风险评估报告Controller
 * 
 * @author ruoyi
 * @date 2025-03-31
 */
@RestController
@RequestMapping("/system/risk")
public class EquipmentRiskAssessmentController extends BaseController
{
    @Autowired
    private IEquipmentRiskAssessmentService equipmentRiskAssessmentService;

    /**
     * 查询安全风险评估报告列表
     */
    @PreAuthorize("@ss.hasPermi('system:risk:list')")
    @GetMapping("/list")
    public TableDataInfo list(EquipmentRiskAssessment equipmentRiskAssessment)
    {
        startPage();
        List<EquipmentRiskAssessment> list = equipmentRiskAssessmentService.selectEquipmentRiskAssessmentList(equipmentRiskAssessment);
        return getDataTable(list);
    }

    /**
     * 导出安全风险评估报告列表
     */
    @PreAuthorize("@ss.hasPermi('system:risk:export')")
    @Log(title = "安全风险评估报告", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, EquipmentRiskAssessment equipmentRiskAssessment)
    {
        List<EquipmentRiskAssessment> list = equipmentRiskAssessmentService.selectEquipmentRiskAssessmentList(equipmentRiskAssessment);
        ExcelUtil<EquipmentRiskAssessment> util = new ExcelUtil<EquipmentRiskAssessment>(EquipmentRiskAssessment.class);
        util.exportExcel(response, list, "安全风险评估报告数据");
    }

    /**
     * 获取安全风险评估报告详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:risk:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(equipmentRiskAssessmentService.selectEquipmentRiskAssessmentById(id));
    }

    /**
     * 新增安全风险评估报告
     */
    @PreAuthorize("@ss.hasPermi('system:risk:add')")
    @Log(title = "安全风险评估报告", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody EquipmentRiskAssessment equipmentRiskAssessment)
    {
        return toAjax(equipmentRiskAssessmentService.insertEquipmentRiskAssessment(equipmentRiskAssessment));
    }

    /**
     * 修改安全风险评估报告
     */
    @PreAuthorize("@ss.hasPermi('system:risk:edit')")
    @Log(title = "安全风险评估报告", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody EquipmentRiskAssessment equipmentRiskAssessment)
    {
        return toAjax(equipmentRiskAssessmentService.updateEquipmentRiskAssessment(equipmentRiskAssessment));
    }

    /**
     * 删除安全风险评估报告
     */
    @PreAuthorize("@ss.hasPermi('system:risk:remove')")
    @Log(title = "安全风险评估报告", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(equipmentRiskAssessmentService.deleteEquipmentRiskAssessmentByIds(ids));
    }
}
